const Sequelize = require("sequelize");
const sequelize = require("../config/database");
const User = require("./User");
const Spot = require("./Spot");
const Comment = sequelize.define("comment", {
  id: {
    type: Sequelize.INTEGER,
    autoIncrement: true,
    primaryKey: true,
  },
  text: {
    type: Sequelize.TEXT,
    allowNull: false,
  },
  userId: {
    type: Sequelize.INTEGER,
    reference: {
      model: User,
      key: "id",
    },
  },
  spotId: {
    type: Sequelize.INTEGER,
    reference: {
      model: Spot,
      key: "id",
    },
  },
});

// Comment.belongsTo(User);
// Comment.belongsTo(Spot);
// Comment.belongsTo(User);
// Comment.belongsTo(Spot);
// Spot.hasMany(Comment);
Comment.belongsTo(Spot);
// Comment.belongsToMany(User, { through: Spot });
// Comment.belongsTo(User, { through: Spot });
// User.hasMany(Comment);
// User.hasMany(Comment);
module.exports = Comment;
